package org.giovanolli.mumi.view.util;

import javax.faces.application.FacesMessage;
import javax.faces.context.FacesContext;

public class FacesContextUtils {

	private static final String RESOURCE_BUNDLE_NAME = "msg";

	public static void addMessageToContext(FacesContext context, String key) {
		String message = context.getApplication().getResourceBundle(context, RESOURCE_BUNDLE_NAME).getString(key);
		FacesMessage msg = new FacesMessage(message);
		FacesContext.getCurrentInstance().addMessage(null, msg);
	}

	public static void addMessageToContext(String key) {
		FacesContext context = FacesContext.getCurrentInstance();
		addMessageToContext(context, key);
	}
}
